﻿@model asMeishi.web.Models.shop
           
@using publicLibrary
@using asMeishi.web.Models
@using asMeishi.web
@using asMeishi.web.Classes;
@{
    int nextStep = (int)(ViewBag.nextStep??0);
    ViewBag.Title = "Edit";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<h2>新建美食店</h2>
    @using (Html.BeginForm())
    {
        <input type="hidden" value="@Model.Id" name="shopId" />
        <input type="hidden" value="false" name="directAction" />
        <div  style="color:red"> @Html.ValidationMessage("create")</div>
       
        switch (nextStep)
        {
            case 1:
        <div>
        <input type="hidden" name="nextStep" value="1" />
            1／5:　输入店名
            <div style="margin:6px 0px; background:#d0d0d0; overflow:hidden;height:2px" >
                <div style=" height:2px; width:160px;" class="sbcolor"></div>
            </div>

            <input type="text" name="name" value="@Model.name"/>
            <div class="formNote">
                @if(ViewBag.someShop !=null){
                    <input type="hidden" name="shopNameVallid" value="true" />
                    <div style="color:Red">有相似的店里存在，为了有别于其它店，建议增加附加名如：@(Model.name)-湖南店、@(Model.name)-自由街店</div>
                    var shops = ViewBag.someShop as IQueryable<shop>;
                    <ul style=" padding:20px;">
                    @foreach(var s in shops){
                        
                        <li><a href="/shop/detail/@s.Id" target="_blank">@s.name</a><span> 访问量:@s.view_number 点评量:@s.comment_number 评分:@(s.sum_score/s.score_number) / @s.score_number</span></li>
                    }
                    </ul>
                }
                第一步:输入你所知道的店的店名
            </div>
        </div>
    
                break;
            case 2:
            <!---导入地址script--->
            <script type="text/javascript" src="/Content/script/address.js"></script>
        <div>
            2／5: 录入店的基本信息
            <div style="margin:6px 0px; background:#d0d0d0; overflow:hidden;height:2px" >
                <div style=" height:2px; width:160px;" class="sbcolor"></div>
            </div>
            <input type="hidden" name="nextStep" value="2" />

            <fieldset>
                <legend>其它名称</legend>
            <input type="text" name="nameCN" value="@Model.nameCN"/>
            </fieldset>
            <fieldset>
                <legend>主菜系</legend>
                <div>
                @Html.myHtmlDom("foodStyle", publicDictApp.get("shopClass"), selectType.多选, Model.foodStyleList.tryToArray());

                </div>
            </fieldset>
            <fieldset>
                <legend>简介</legend>
                <div>
                    @Html.TextAreaFor(model => model.intro, new {@class="textareaBig" })
                </div>
            </fieldset>
            <fieldset>
                <legend>地址</legend>
                <label> 所在市
                    <input name="city" type="text" id="city" value="@Model.city" onclick="showAddressTip(this,'city')" />
  
                </label>
                <label>
                所在区域
                    <input name="area" type="text" id="area" value="@Model.area" onclick="showAddressTip(this,'area','city')"/>
                </label>
                <label>
                所在街道
                    <input name="street" type="text" id="street" value="@Model.street" onclick="showAddressTip(this,'street','area')"/>
                </label>
            </fieldset>
            

        </div>

           break;
            case 3:
        <div>
        3／5: 录入店的扩展信息
            <div style="margin:6px 0px; background:#d0d0d0; overflow:hidden;height:2px" >
                <div style=" height:2px; width:160px;" class="sbcolor"></div>
            </div>
        <input type="hidden" name="nextStep" value="3" />
            <fieldset>
                <legend>其它信息</legend>
                <div>电话
                    @Html.TextBoxFor(model => model.telephone)
                </div>
                <div>规模
                    @Html.DropDownListFor(model => model.size, new SelectList(publicDictApp.get("shopSize"), "Key", "Value", Model.size));
                </div>

                <div>环境
                    @Html.DropDownListFor(model => model.environment, new SelectList(publicDictApp.get("shopEnvironment"), "Key", "Value", Model.size));
                </div>
                <div>连锁
                @Html.myHtmlDom("head", publicDictApp.get("shopHead"), selectType.单选, Model.head.ToString());
                </div>
            </fieldset>
            <fieldset>
                <legend>硬件条件</legend>
                <div>
                    @Html.myHtmlDom("utilityTags", publicDictApp.get("shopUtilityTag"), selectType.多选, Model.utilityTags.tryToArray())
                </div>
            </fieldset>
            <fieldset>
                <legend>适合几人吃</legend>
                <div>
                    @Html.myHtmlDom("fit", publicDictApp.get("shopFit"), selectType.多选, Model.fit.trySplit("|"))
                </div>
            </fieldset>

        </div>
               break;
            case 4:
        <div>
        4／5: 做个点评吧
            <div style="margin:6px 0px; background:#d0d0d0; overflow:hidden;height:2px" >
                <div style=" height:2px; width:160px;" class="sbcolor"></div>
            </div>
        <input type="hidden" name="nextStep" value="4" />

                @Html.Partial("p_addComment", new commentC().getByShopId(Model.Id).FirstOrDefault() ?? new commentC().createDefault(userC.loginUser))

            <fieldset>
            <legend>推荐个菜吧</legend>
            @Html.Partial("p_addfood")
        </fieldset>

        </div>
       break;
            case 5:
       <div>
       5／5: 发布它吗？
            <div style="margin:6px 0px; background:#d0d0d0; overflow:hidden;height:2px" >
                <div style=" height:2px; width:160px;" class="sbcolor"></div>
            </div>       
        <input type="hidden" name="nextStep" value="5" />
    <script>
        function step5submit(it) {

            $("#aaction").val(it);

            document.forms[0].submit();
        }
    </script>
        <input type="hidden" name="aaction" id="aaction" value="" />
        <button type="button"  onclick="step5submit('release')">发布</button>
        @if (nextStep != 1 && nextStep != 0)
        {
            <button type="button"  onclick="step5submit('reCreate')" >重写增写</button>
            <button type="button"  onclick="step5submit('delete')">删除</button>
        }
        </div>
        break;
        }

    if (nextStep != 5)
    {
    <div style=" text-align:right"><button type="submit" class="btn btn-big">提交</button></div>
    }

}
